From 6e017f7ed5a6be99ab3ac8d4ba29c3a6cf82d009 Mon Sep 17 00:00:00 2001 From: "mjw@wray-m-3.hpl.hp.com" Date: Thu, 2 Sep 2004 12:04:03 +0000 Subject: [PATCH] bitkeeper revision 1.1159.1.118 (41370c33N7_5pjKepga6V4ZmyTSNnQ) Add support for maxmem in xm create and config. --- docs/xen_config.html | 1 + tools/python/xen/xend/XendDomainInfo.py | 28 ++++++++++++++++++++++++- tools/python/xen/xm/create.py | 6 ++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/docs/xen_config.html b/docs/xen_config.html index 95493f7556..447ebeec53 100644 --- a/docs/xen_config.html +++ b/docs/xen_config.html @@ -60,6 +60,7 @@ The top-level element, a virtual machine configuration.
  • name: string, required. Domain name.
  • id: int, optional, default generated. Domain unique id.
  • memory: int, required. Domain memory in MB. +
  • maxmem: int, optional. Maximum domain memory in MB.
  • cpu: int, optional. Cpu to run on.
  • cpu_weight, float, optional, default 1. Cpu weight - controls share of CPU.
  • image: linux | netbsd | ..., required. Domain image (OS-specific element). diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index 88a9d5b5c3..b86167143b 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -831,6 +831,14 @@ class XendDomainInfo: self.config.remove(['device', dev_config]) dev.destroy() + def configure_memory(self): + """Configure vm memory limit. + """ + maxmem = sxp.get_child_value(self.config, "maxmem") + if maxmem is None: + maxmem = self.memory + xc.domain_setmaxmem(self.dom, maxmem_kb = maxmem * 1024) + def configure_console(self): """Configure the vm console port. """ @@ -1140,11 +1148,28 @@ def vm_field_ignore(vm, config, val, index): @param vm: virtual machine @param config: vm config - @param val: vfr field + @param val: config field @param index: field index """ pass +def vm_field_maxmem(vm, config, val, index): + """Configure vm memory limit. + + @param vm: virtual machine + @param config: vm config + @param val: config field + @param index: field index + """ + maxmem = sxp.child0(val) + if maxmem is None: + maxmem = vm.memory + try: + maxmem = int(maxmem) + except: + raise VmError("invalid maxmem: " + str(maxmem)) + xc.domain_setmaxmem(vm.dom, maxmem_kb = maxmem * 1024) + # Register image handlers. add_image_handler('linux', vm_image_linux) add_image_handler('netbsd', vm_image_netbsd) @@ -1165,3 +1190,4 @@ add_config_handler('device', vm_field_ignore) add_config_handler('backend', vm_field_ignore) # Register other config handlers. +add_config_handler('maxmem', vm_field_maxmem) diff --git a/tools/python/xen/xm/create.py b/tools/python/xen/xm/create.py index 01ab1e8a12..5dfa698f9d 100644 --- a/tools/python/xen/xm/create.py +++ b/tools/python/xen/xm/create.py @@ -99,6 +99,10 @@ gopts.var('memory', val='MEMORY', fn=set_int, default=128, use="Domain memory in MB.") +gopts.var('maxmem', val='MEMORY', + fn=set_int, default=None, + use="Maximum domain memory in MB.") + gopts.var('cpu', val='CPU', fn=set_int, default=None, use="CPU to run the domain on.") @@ -310,6 +314,8 @@ def make_config(vals): config = ['vm', ['name', vals.name ], ['memory', vals.memory ]] + if vals.maxmem: + config.append(['maxmem', vals.maxmem]) if vals.cpu is not None: config.append(['cpu', vals.cpu]) if vals.cpu_weight is not None: -- 2.30.2